<template>
  <div class ="news">
      <h2>我是News组件</h2>
       <h2>我是News组件,School组件传递的学校名称为：{{SchoolName}}</h2>
      <ul>
          <li v-for="news in newsList" :key="news.id">{{news.title}}</li>
      </ul>
  </div>
</template>

<script>
  export default {
      name:'News',
      data(){
          return {
              newsList:[
                  {id:'001',title:'震惊！尚硅谷一男老师竟然'},
                  {id:'002',title:'重要通知，有微信的都要注意了'}
              ],
              'SchoolName':'',
          }
      },
      mounted(){
          this.$bus.$on('haha',(val)=>{
              console.log('我是News组件，我收到了别人传过来的数据',val)
              this.SchoolName = val
          })
      },
      beforeDestroy() {
          this.$bus.$off('haha')
      },
  }
</script>

<style scoped>
  .news{
    background-color: skyblue;
    padding:20px;
  }
</style>